﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Boggle;

using NUnit.Framework;

namespace BoggleTests
{
    /// <summary>
    /// Tests the OptimisticDictionary.
    /// </summary>
    public class TestOptimisticDictionary
    {
        /// <summary>
        /// Tests the dictionary's constructor.
        /// </summary>
        [Test]
        public void TestCtor()
        {
            var dict = new OptimisticDictionary();
            Assert.IsFalse(dict.IsDefineSupported);
            Assert.IsNotNull(dict.Description);
        }

        #region IsWord Tests

        /// <summary>
        /// Tests the dictionary's IsWord method.
        /// </summary>
        /// <param name="word"></param>
        /// <returns></returns>
        [Test, TestCaseSource("GetIsWordCases")]
        public Boolean TestIsWord(String word)
        {
            var dict = new OptimisticDictionary();
            return dict.IsWord(word);
        }

        /// <summary>
        /// Provides test cases for the IsWord method.
        /// </summary>
        /// <returns></returns>
        private IEnumerable<ITestCaseData> GetIsWordCases()
        {
            yield return new TestCaseData(null).Returns(true);
            yield return new TestCaseData(String.Empty).Returns(true);
            yield return new TestCaseData("a").Returns(true);
            yield return new TestCaseData("hello").Returns(true);
            yield return new TestCaseData("qwertyuiop").Returns(true);
        }

        #endregion

        /// <summary>
        /// Tests that this dictionary's DefineWord method throws
        /// an appropriate exception.
        /// </summary>
        [Test, ExpectedException(typeof(NotImplementedException))]
        public void TestDefine()
        {
            var dict = new OptimisticDictionary();
            dict.Define("fish");
        }
    }
}
